/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.mycompany.managedbean;

import java.util.List;
import javax.faces.model.ListDataModel;
import org.primefaces.model.SelectableDataModel;

/**
 *
 * @author DOWN
 */
public class DataObjectModel extends ListDataModel<DataObject> implements SelectableDataModel<DataObject> {

    public DataObjectModel() {
    }
    
    public DataObjectModel(List<DataObject> datas) {
        super(datas);
    }

    @Override
    public Object getRowKey(DataObject t) {
        return t.getUniqueID();
    }

    @Override
    public DataObject getRowData(String rowKey) {
        List<DataObject> datas = (List<DataObject>) getWrappedData();
        for (DataObject dataObject : datas) {
            if (dataObject.getUniqueID().equals(rowKey)) {
                return dataObject;
            }
        }
        return null;
    }

}
